package com.wanxi.service.impl;

import com.wanxi.dao.CuisineDao;
import com.wanxi.dao.impl.CuisineImpl;
import com.wanxi.model.CuisineModel;
import com.wanxi.model.ResultModel;
import com.wanxi.service.CuisineService;

public class CuisineServiceImpl implements CuisineService {
    private CuisineDao cuisineDao = new CuisineImpl();

    @Override
    public ResultModel enable(CuisineModel cuisineModel) {
//        CuisineDao cuisineDao = new CuisineImpl();
//        int count = cuisineDao.enable(cuisineModel);
//        ResultModel resultModel = new ResultModel();
//        resultModel.setCount(count);
//        return resultModel;
        return ResultModel.getResult(cuisineDao.enable(cuisineModel));
    }

    @Override
    public ResultModel add(CuisineModel cuisineModel) {
//        CuisineDao cuisineDao = new CuisineImpl();
//        int count = cuisineDao.add(cuisineModel);
//        ResultModel resultModel = new ResultModel();
//        resultModel.setCount(count);
//        return resultModel;
        return ResultModel.getResult(cuisineDao.add(cuisineModel));
    }

    @Override
    public ResultModel update(CuisineModel cuisineModel) {
//        CuisineDao cuisineDao = new CuisineImpl();
//        int count = cuisineDao.update(cuisineModel);
//        ResultModel resultModel = new ResultModel();
//        resultModel.setCount(count);
//        return resultModel;
        return ResultModel.getResult(cuisineDao.update(cuisineModel));
    }

    @Override
    public ResultModel delete(CuisineModel cuisineModel) {
//        CuisineDao cuisineDao = new CuisineImpl();
//        int count = cuisineDao.delete(cuisineModel);
//        ResultModel resultModel = new ResultModel();
//        resultModel.setCount(count);
//        return resultModel;
        return ResultModel.getResult(cuisineDao.delete(cuisineModel));
    }

    @Override
    public ResultModel findById(CuisineModel cuisineModel) {
//        CuisineDao cuisineDao = new CuisineImpl();
//        CuisineModel model = cuisineDao.findById(cuisineModel);
//        ResultModel resultModel = new ResultModel();
//        resultModel.setData(model);
//        return resultModel;
        return ResultModel.getResult(cuisineDao.findById(cuisineModel));
    }

    @Override
    public ResultModel findAll(CuisineModel cuisineModel) {
//        CuisineDao cuisineDao = new CuisineImpl();
//        List<CuisineModel> list = cuisineDao.findAll(cuisineModel);
//        int count = cuisineDao.count(cuisineModel);
//        ResultModel resultModel = new ResultModel();
//        resultModel.setData(list);
////        如果查询的时候有分页，已经有每一页多少条，那么要得到最后一页，必须要有总条数
////        所以，必须在查询所有的时候同时查询总条数
//
//        resultModel.setCount(count);
//        return resultModel;
        return ResultModel.getResult(cuisineDao.findAll(cuisineModel), cuisineDao.count(cuisineModel));
    }


    @Override
    public ResultModel count(CuisineModel cuisineModel) {
//        CuisineDao cuisineDao = new CuisineImpl();
//        int count = cuisineDao.count(cuisineModel);
//        ResultModel resultModel = new ResultModel();
//        resultModel.setCount(count);
//        return resultModel;
        return ResultModel.getResult(cuisineDao.count(cuisineModel));
    }


}
